from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


class Base:
    def __init__(self,driver,timeout=5,poll_frequency=0.5):
        self.driver = driver
        self.timeout = timeout
        self.poll_frequency = poll_frequency
        self.wait = WebDriverWait(self.driver,self.timeout,self.poll_frequency)
    def open(self,url):
        self.driver.get(url)
        self.driver.maximize_window()
    def find(self,locator):
        return self.wait.until(EC.visibility_of_element_located(locator))      
    def finds(self,locator):
        return self.wait.until(EC.visibility_of_all_elements_located(locator))
    def presence(self,locator):
        return self.wait.until(EC.presence_of_element_located(locator))
    def presences(self,locator):
        return self.wait.until(EC.presence_of_all_elements_located(locator))
    def click(self,locator):
        self.find(locator).click()
    def input(self,locator,value):
        self.find(locator).send_keys(value)
    def clear(self,locator):
        self.find(locator).clear()
    






